package com.lht.arithmetic.skipList;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-10-07
 */
public class SkipListDemo {

    public static void main(String[] args) {

        List<Student> students = new ArrayList<>();
        Random r = new Random();
        for (int i = 0; i < 10000; i++) {
            Student student = new Student(UUID.randomUUID().toString(), r.nextInt(10000));
            students.add(student);
        }
        SkipList<Student> skipList = new SkipList<>();
        for(Student s : students) {
            skipList.add(s);
        }
        skipList.list();
        skipList.indexList();
        System.out.println(skipList.getCapacity());
        System.out.println(skipList.getHeight());
    }
}

class Student implements Comparable<Student> {

    private String name;

    private int age;

    public Student() {
        this(null, 0);
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
